import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {Env} from '../../../environments/Env';

@Injectable({
  providedIn: 'root'
})
export class HomeService {

  constructor(private http: HttpClient) {
  }

  /**
   * 获取最新文章
   */
  public getLatestArticles(): Observable<any> {
    return this.http.get(`${Env.getDomain()}/home/findAll`);
  }

  /**
   * 获取热门文章
   */
  public getHotArticles(): Observable<any> {
    return this.http.get(`${Env.getDomain()}/home/findHot`);
  }

  /**
   * 根据id获取文章详情
   */
  public getArticleDetail(params: any): Observable<any> {
    return this.http.get(`${Env.getDomain()}/home/find`, {params});
  }
}
